set -x

clean=off
run=off
test=off
usage() {                                      # Function: Print a help message.
  echo "Usage: $0 [ -t --test -c --clean -r --run]" 1>&2 
}
exit_abnormal() {                              # Function: Exit with error.
  usage
  exit 1
}
while getopts "ctr" options; do              # Loop: Get the next option;
  case "${options}" in                         # 
    t)                                         # If the option is n,
	test=on ;;
    c)                                         # If the option is n,
	clean=on ;;
    r)                                         # If the option is n,
	run=on
      ;;
    :)                                         # If expected argument omitted:
      echo "Error: -${OPTARG} requires an argument."
      exit_abnormal                            # Exit abnormally.
      ;;
    *)                                         # If unknown (any other) option:
      exit_abnormal                            # Exit abnormally.
      ;;
  esac
done
if [ "$clean" = "on" ]; then
    rm -rf CMakeFiles build CMakeCache.txt *.exe *.sublime-project Makefile cmake_install.cmake *.sln *.vcxproj *.vcxproj.filters
fi

if [ "$test" = "on" ]; then
    python3 tst.py
fi

exit 0                                         # Exit normally.
